/*
	Title: 01_Figure2.do
	Paper: Brauning, Ivashina, Ozdagli (2025)
	Description: Figure 2 - Financial covenants in the leverage-loan market 
*/

/*------------------------------------------------------------------------------
								  Figure 2
------------------------------------------------------------------------------*/
// Import Panel A data
use "$data_path/Figure2A.dta", clear 

// Label Variables 
label var CapitalExpenditures   "Capital expenditures"
label var CashInterestCoverage	"Cash interest coverage"
label var DebtEBITDA			"Debt/EBITDA"
label var FixedChargeCoverage	"Fixed charge coverage"
label var InterestCoverage		"Interest coverage"
label var SeniorDebtEBITDA		"Senior debt/EBITDA"

// Create Figure 2A
set scheme s1color
twoway (line DebtEBITDA year, lwidth(medthick) lcolor(blue)) ///
	   (line InterestCoverage year, lwidth(medthick) lcolor(orange)) ///
	   (line SeniorDebtEBITDA year, lwidth(medthick) lpattern(dash)) ///
	   (line FixedChargeCoverage year, lwidth(medthick) lpattern(dash)) ///
	   (line CashInterestCoverage year, lwidth(medthick) lpattern(shortdash_dot)) ///
	   (line CapitalExpenditures year, lwidth(medthick) lpattern(shortdash_dot) lcolor(red)), ///
		ytitle("Percentage of leveraged loans") legend(cols(2) region(lcolor(white)) pos(6)) ///
		xlabels(, nogrid) ylabels(, nogrid) /// 
		xtitle("") /// 
		plotregion(margin(t+2 b+2 r+6)) ///
		graphregion(margin(sides) style(none)) ///
		ysize(1080pt) xsize(1500pt) scheme(stcolor) ///
		name(Figure2A, replace)

graph export "$figures_path/Figure2A.png", replace 


// Import Panel B data 
use "$data_path/Figure2B.dta", clear 

// Create Figure 2B 
set scheme s1color
graph bar uptotwo three fourplus, over(year) ///
	  bar(1 , fcolor(blue)) ///
	  bar(2, fcolor(orange)) ///
	  bar(3,fcolor(green)) ///
	  ytitle("Percent of leveraged loans" " ") ///
	  legend(order( 1 "1-2 Covenants" 2 "3 Covenants" 3 "4+ Covenants") rows(1) ///
	  region(lcolor(white))) graphregion(color(white)) ///
	  name(Figure2B, replace)
	  
graph export "$figures_path/Figure2B.png", replace 